package com.lpit.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lpit.dto.ArticleManagementDto;
import com.lpit.pojo.Article;
import com.lpit.result.ResponseResult;
import com.lpit.service.ArticleManagementService;
import com.lpit.vo.ArticleManagementVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article/management")
@Slf4j
public class ArticleManagementController {

    @Autowired
    private ArticleManagementService articleManagementService;

    /**
     * 查看所有的文章
     * @param article
     * @return
     */
    @GetMapping("/list")
    public ResponseResult<Page<ArticleManagementVo>> list(ArticleManagementDto article){
        return articleManagementService.list(article);
    }

    /**
     * 修改文章
     * @return
     */
    @PutMapping
    public ResponseResult modify(@RequestBody Article article){
        return articleManagementService.modify(article);
    }

    /**
     * 删除文章
     * @return
     */
    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return articleManagementService.delete(id);
    }

    /**
     * 置顶文章
     * @return
     */
    @PutMapping("/contentTop/{id}")
    public ResponseResult contentTop(@PathVariable Integer id){
        return null;
    }

    /**
     * 内容撤回，存放到草稿箱
     * @return
     */
    @PutMapping("/revocation/{id}")
    public ResponseResult revocation(@PathVariable Integer id){
        return null;
    }
}
